<template>
  <nuxt />
</template>
<script>
import HeyUI from "heyui";

export default {
  created() {
    HeyUI.config("dict.keyName", "value");
    HeyUI.config("dict.titleName", "label");

    if (sessionStorage.getItem("store")) {
      this.$store.replaceState(
        Object.assign(
          {},
          this.$store.state,
          JSON.parse(sessionStorage.getItem("store"))
        )
      );
    }
    window.addEventListener("beforeunload", () => {
      sessionStorage.setItem("store", JSON.stringify(this.$store.state));
    });
    this.$router.beforeEach((to, from, next) => {
      HeyUI.$LoadingBar.start();
      next();
    });
    this.$router.afterEach(() => {
      HeyUI.$LoadingBar.success();
    });
    if (!this.$store.state.LOGIN_FLAG) {
      this.$router.push("/login");
      return;
    }
  },
  mounted() { }
};
</script>